/* 
 * 1. be noticed, comments should start with '##'.
 * 2. it will auto delete space.
 * 3. but itemName and itemValue can have space.
 */

#ifndef INI_PARSER_HJ
#define INI_PARSER_HJ

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "jlist.h"


#define MAX_NAME_LEN 128
#define MAX_VAL_LEN 256
#define MAX_INI_FILE_LEN (1024*300)
#define MAX_INTEGER_LEN 16
#define MAX_LINE_LEN (MAX_INI_FILE_LEN + 1) 


typedef struct _SIniItem {
	char m_acName[MAX_NAME_LEN];
	char m_acVal[MAX_VAL_LEN];
}SIniItem, *PSIniItem;

typedef struct _SIniSect {
	char m_acName[MAX_NAME_LEN];
	SList * m_pstItemList;
}SIniSect, *PSIniSect;

typedef struct _SIniFile {
	SList * m_pstSectList;
}SIniFile, *PSIniFile;

PSIniFile
init_pstCreate();

/*
 * Please remember to call ini_vClear() if you don't want to use iniParse.
 */
void 
ini_vClear(PSIniFile pstIniFile);

int
ini_iLoadFromFile(PSIniFile pstIniFile, const char *pcFile);

int 
ini_iPutItemString(PSIniFile pstIniFile, const char* pcSect, const char* pcItem, const char* pcValue);

int 
int_iPutItemInteger(PSIniFile pstIniFile, const char* pcSect, const char* pcItem, int iValue);

const char *
ini_pcGetItemString(PSIniFile pstIniFile, const char* pcSect, const char* pcItem, const char* pcDefault);

int 
ini_iGetItemInteger(PSIniFile pstIniFile, const char* pcSect, const char* pcItem, int iDefault);

void 
ini_vRemoveSect(PSIniFile pstIniFile, const char* pcSect);

void
ini_vRemoveItem(PSIniFile pstIniFile, const char* pcSect, const char* pcItem);

int 
ini_iSaveToFile(PSIniFile pstIniFile, const char* pcFileName);


#ifdef __cplusplus
}
#endif
#endif


